<%@page import="controller.*"%>
<%@page import="manager.*"%>
<%@page import="java.util.ArrayList"%>
<%@page import="util.*"%>

<jsp:useBean id="DateUtil" scope="page" class="util.DateUtil" />

<%@ taglib prefix="stripes"
	uri="http://stripes.sourceforge.net/stripes-dynattr.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<stripes:layout-render name="/student/master-page.jsp">
	<stripes:layout-component name="head">
		<style>
.table thead>tr>td,.table tbody>tr>td {
	vertical-align: middle;
}

.table .label {
	width: 100%;
	display: block;
}
</style>
	</stripes:layout-component>
	<stripes:layout-component name="content">

		<center>
			<stripes:messages />
			<stripes:errors />
		</center>

		<div class="container legend">
			<div class="row">
				<div class="col-md-12">
					<span class="label label-default">Legend:</span> <span
						class="label label-success">Successful</span> <span
						class="label label-danger">Unsuccessful</span> <span
						class="label label-primary">Pending</span>
				</div>
			</div>
		</div>

		<div class="row">
			<div class="col-md-12">
				<div class="panel panel-info">
					<div class="panel-heading">
						<h3 class="panel-title">My Bids</h3>
					</div>

					<table class="table table-striped table-condensed">
						<thead>
							<tr>
								<th style="text-align: center" class="col-md-1">Course</th>
								<th style="text-align: center" class="col-md-1">Section</th>
								<th class="col-md-2">Date/Time</th>
								<th class="col-md-2">Instructor</th>
								<th class="col-md-1">Amount</th>
								<th style="text-align: center" class="col-md-1">Status</th>
								<th style="text-align: center" class="col-md-1">Round</th>
								<th class="col-md-1">&nbsp;</th>
								<th class="col-md-2">&nbsp;</th>
							</tr>
						</thead>
						<tbody>

							<c:set var="successfulBids"
								value="${actionBean.getSuccessfulBidsForLoggedInStudent()}" />
							<c:set var="unsuccessfulBids"
								value="${actionBean.getUnsuccessfulBidsForLoggedInStudent()}" />
							<c:set var="pendingBids"
								value="${actionBean.getPendingBidsForLoggedInStudent()}" />

							<c:if test="${empty successfulBids && empty pendingBids && empty unsuccessfulBids}">
								<tr>
									<td colspan="9"><i
										class="glyphicon glyphicon-remove-circle"></i> You have not
										placed any bids. Do you want to <a
										href="${pageContext.request.contextPath }/courses/">Bid
											Courses</a>?
								</tr>
							</c:if>

							<c:forEach items="${successfulBids }" var="eachBid">
								<%@include file="/student/layout/bid-table-row.jsp"%>
							</c:forEach>

							<c:forEach items="${unsuccessfulBids }" var="eachBid">
								<%@include file="/student/layout/bid-table-row.jsp"%>
							</c:forEach>

							<c:forEach items="${pendingBids }" var="eachBid">
								<%@include file="/student/layout/bid-table-row.jsp"%>
							</c:forEach>



						</tbody>
					</table>
				</div>
			</div>
		</div>

	</stripes:layout-component>

	<stripes:layout-component name="end">
		<script>
			$(function() {

				$('.drop-btn').click(
						function(e) {
							e.preventDefault();
							myHref = $(this).attr('href');
							bootbox.confirm("Are you sure you want to drop <b>"
									+ name + "</b>?", function(result) {
								console.log("Confirm result: " + result);
								if (result) {
									window.location.href = myHref;
								}
							});
						});

			});
		</script>
	</stripes:layout-component>

</stripes:layout-render>